<template>
    <div class="photoinfo-container">
        <h3 class="title">{{ photoinfo.title }}</h3>
        <p class="info">
            <span>发表时间：{{ photoinfo.add_time | dateFormat }}</span>
            <span>点击次数: {{ photoinfo.click }}</span>
        </p>
        <hr>

        <!-- 缩略图区域 -->
        <div class="thumb-img-list">
            <img :src="item.src" v-for="(item,i) in photolist" :key="i">
        </div>

        <!-- 内容区域 -->
        <div class="content" v-html="photoinfo.content"></div>

        <!-- 评论子组件 -->
        <comment :newsid="id"></comment>
    </div>
</template>

<script>
// 导入评论子组件
import comment from '../sub-conponents/Comment.vue'
export default {
    data(){
        return{
            photoinfo:{},
            photolist:[] //缩略图数组
        }
    },
    created(){
        this.getPhotoInfo(),
        this.getThnmblmg()
    },
    methods:{
        async getPhotoInfo(){
            const {data} = await this.$http.get("http://api.cms.liulongbin.top/api/getimageInfo/" + this.id);
            if(data.status === 0){
                return this.photoinfo = data.message[0];
            }
        },
        async getThnmblmg(){
            //获取图片的缩略图数据
            const {data} = await this.$http.get("http://api.cms.liulongbin.top/api/getthumimages/" + this.id);
            if(data.status === 0){
                return this.photolist = data.message;
            }
        }
    },
    props:["id"],
    components:{
        comment
    }
}
</script>

<style lang="scss" scoped>
    .photoinfo-container{
        padding: 3px;
    }
    .title{
        font-size: 15px;
        text-align: center;
        margin: 15px 0;
        color: #26a2ff;
    }
    .info{
        font-size: 13px;
        display: flex;
        justify-content: space-between;
    }
    .content{
        font-size: 13px;
        line-height: 30px;
    }
</style>